package org.melanesia.beans;

/**
 * Getter interface. Implementations of this interface should
 * <strong>know</strong> the property name and the path to access it.
 *
 * @author marcin.kielar
 */
interface Getter {

    /**
     * Returns the value of the property. The name of the property can be
     * simple, or composite. The idea of composite properties is discussed in
     * {@link org.melanesia.beans.Setter#set(Object, Object, java.util.Map)}.
     *
     * The special case with implementations of this interface for composite
     * properties is null handling. If for example, one tries to access property
     * <code>teacher.person.address.street</code>, where
     * <code>person.getAddress()</code> returns null, the value returned should
     * be null.
     *
     * This applies to any other property in the path. Basically, if any
     * "parent" property in the path is null, then the value returned by this
     * method, should also be null (i.e. no exception should be thrown).
     *
     * @param bean
     *            bean to access the property
     * @return property value
     */
    Object get(Object bean);

    /**
     * Returns the type of the values returned by the {@link #get(Object)}
     * method. This may be interpreted as the type of the property.
     *
     * @return getter return type
     */
    Class<?> getReturnType();
}
